package com.koron.order.overhaul.feign.fallback;

import com.koron.bean.base.Response;
import com.koron.order.overhaul.bean.dto.Equipment;
import com.koron.order.overhaul.feign.EquipmentFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * @author twcao
 * @title: EquipmentFeignFallback
 * @projectName GDH_EAM_V2
 * @description: 熔断降级
 * @date 2021/10/1116:22
 */
@Slf4j
@Component
public class EquipmentFeignFallback implements FallbackFactory<EquipmentFeign> {

    @Override
    public EquipmentFeign create(Throwable e) {
        return new EquipmentFeign() {
            @Override
            public Response<Equipment> queryById(String id) {
                log.error(e.getMessage(), e);
                return Response.fail(e.getMessage());
            }

            @Override
            public Response<Map<String, Map<String, String>>> getTowerParams(List<String> equipmentIds) {
                log.error(e.getMessage(), e);
                return Response.fail(e.getMessage());
            }
        };
    }
}
